<?php
/**
 *޸by jeff zeng 2007-4-5
 *{webcontrol type='Clientoptions' selected=''}
 *以联动select方式显示供应商控件
 *因为建立的客户不多，所以改为普通的select控件
 */
function _ctlClientoptions($name,$params) {
//	$name = $params[id];
//	if ($params[disabled]) $dis = ' disabled';
//	$html = "<select name='$name' id='$name' check='^0$' warning='请选择客户' onclick=\"popClient(this)\"".$dis.">";
//	if (is_array($params[selected])) {
//		$html .= "<option value='$selected[id]'>$selected[compName]</option>";
//	} else {
//		$mClient = & FLEA::getSingleton('Model_Jichu_Client');
//		$arr = $mClient->find(array(id=>$params[selected]));
//		$html .= "<option value='$arr[id]'>$arr[compName]</option>";
//	}
//	$html .= "</select>";
	$m = & FLEA::getSingleton('Model_Jichu_Client');
	$sql = "select * from jichu_client where isStop=0";
	//dump($sql);
	$rowset = $m->findBySql($sql);
	//dump($rowset);exit;
	$kg = & FLEA::getAppInf('khqcxs');
	$ret = "<option value='' style='color:#ccc'>选择客户</option>";
	foreach($rowset as & $v) {
	//根据开关变量khqcxs判断是显示客户全称还是显示客户助记码
		if($kg) $temp = $v['compName'];
		else {
			if($v['zhujiCode']=='') $temp = $v['compName'];
			else $temp = $v['zhujiCode'];
		}
		//$temp = 'aa';
		//$ret .= "<option value='{$v['id']}'>{$temp}</options>";
		
		$ret .= "<option value='{$v['id']}'";
		if($params['selected']==$v['id']) $ret .= " selected";
		$ret .= ">{$temp}</option>";
		
		
	}
	return $ret;
}
?>